<template>
  <div class="arm-list">
    <TopBar></TopBar>
    <!-- <SecondaryBanner :bannerData="devBannerList"></SecondaryBanner> -->
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item class="clickable-item"
                            :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>兼容性认证</el-breadcrumb-item>
        <el-breadcrumb-item class="now-link clickable-item">认证结果</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <div class="content-wrapper">
      <ul class="content">
        <li class="content-item"
            v-for="(armItem, armIndex) in contentData"
            :key="armIndex"
            @click="goDetail(armItem)">
          <div class="item-status"
               :class="{
              certification: armItem.attestStatus === 1,
              'under-certification': armItem.attestStatus === 2,
            }"></div>
          <div class="item-img-wrapper">
            <img :src="armItem.logoImage"
                 alt="" />
          </div>
          <h3 class="item-title">{{armItem.source}}{{ armItem.name }}</h3>
          <div class="item-origin"><span>版本: </span>{{ armItem.osVersion }}</div>
        </li>

        <div class="pagination">
          <el-pagination background
                         layout="prev, pager, next"
                         @current-change="currentChange"
                         @prev-click="prevClick"
                         @next-click="nextClick"
                         :page-count="totalPage"
                         :page-size="pageSize">
          </el-pagination>
        </div>
      </ul>
    </div>
    <Footer></Footer>
  </div>
</template>

<script>
import SecondaryBanner from "../components/commonComponent/secondaryBanner";
import Footer from "../components/commonComponent/footer.vue";
import TopBar from "../components/commonComponent/topBar.vue";
import { mapActions, mapState } from "vuex";
export default {
  name: "ArmList",
  data () {
    return {
      pagerCount: 7, //页码按钮的数量
      isPhone: false,
      screenWidth: document.body.clientWidth,
      // contentData: [
      //   {
      //     id: "1",
      //     name: "小熊派BearPi",
      //     description: "定位有什么,要什么,放弃什么",
      //     logoImage: require("../assets/images/arm-item.png"),
      //     url: "https//www.baidu.com",
      //     source: "张三",
      //     attestStatus: 1,
      //     sort: 1,
      //   },
      //   {
      //     id: "1",
      //     name: "小熊派BearPi",
      //     description: "定位有什么,要什么,放弃什么",
      //     logoImage: require("../assets/images/arm-item.png"),
      //     url: "https//www.baidu.com",
      //     source: "张三",
      //     attestStatus: 1,
      //     sort: 1,
      //   },
      //   {
      //     id: "1",
      //     name: "小熊派BearPi",
      //     description: "定位有什么,要什么,放弃什么",
      //     logoImage: require("../assets/images/arm-item.png"),
      //     url: "https//www.baidu.com",
      //     source: "张三",
      //     attestStatus: 1,
      //     sort: 1,
      //   },
      //   {
      //     id: "1",
      //     name: "小熊派BearPi",
      //     description: "定位有什么,要什么,放弃什么",
      //     logoImage: require("../assets/images/arm-item.png"),
      //     url: "https//www.baidu.com",
      //     source: "张三",
      //     attestStatus: 1,
      //     sort: 1,
      //   },
      //   {
      //     id: "1",
      //     name: "小熊派BearPi",
      //     description: "定位有什么,要什么,放弃什么",
      //     logoImage: require("../assets/images/arm-item.png"),
      //     url: "https//www.baidu.com",
      //     source: "张三",
      //     attestStatus: 2,
      //     sort: 1,
      //   },
      //   {
      //     id: "1",
      //     name: "小熊派BearPi",
      //     description: "定位有什么,要什么,放弃什么",
      //     logoImage: require("../assets/images/arm-item.png"),
      //     url: "https//www.baidu.com",
      //     source: "张三",
      //     attestStatus: 1,
      //     sort: 1,
      //   },
      //   {
      //     id: "1",
      //     name: "小熊派BearPi",
      //     description: "定位有什么,要什么,放弃什么",
      //     logoImage: require("../assets/images/arm-item.png"),
      //     url: "https//www.baidu.com",
      //     source: "张三",
      //     attestStatus: 1,
      //     sort: 1,
      //   },
      //   {
      //     id: "1",
      //     name: "小熊派BearPi",
      //     description: "定位有什么,要什么,放弃什么",
      //     logoImage: require("../assets/images/arm-item.png"),
      //     url: "https//www.baidu.com",
      //     source: "张三",
      //     attestStatus: 2,
      //     sort: 1,
      //   },
      // ],
      pageSize: 8,
      pageNum: 1,
      category: 1,
    };
  },
  components: {
    SecondaryBanner,
    Footer,
    TopBar,
  },
  watch: {
    screenWidth (newVal) {
      if (newVal < 768) this.pagerCount = 5;
      else this.pagerCount = 7;
    },
  },
  computed: {
    ...mapState({
      contentData: (state) => state.developData.developmentBatchList,
      devBannerList: (state) => state.subBanner.devBannerList,
      totalPage: (state) => state.developData.totalPage,
    }),
  },
  created () {
    let phonewid = document.documentElement.clientWidth < 768;
    if (document.documentElement.clientWidth < 768) this.pagerCount = 5;
    else this.pagerCount = 7;
    let currentId = this.$route.query.id;
    if (phonewid) {
      this.category = 2;
    } else {
      this.category = 1;
    }
    this.getQueryCarousel({
      type: this.$route.query.id,
      category: this.category,
      currentId: currentId,
    });
    this.getQueryDevelopmentBatch({
      pageNum: this.pageNum,
      pageSize: this.pageSize,
    });
  },
  methods: {
    ...mapActions(["getQueryCarousel", "getQueryDevelopmentBatch"]),
    goDetail (item) {
      let u = navigator.userAgent;
      let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1;
      let isIos = !!u.match(/\(i[^;]+;(U;)? CPU.+Mac OS X/);
      console.log(item);
      if (item.url) {
        if (isIos) {
          window.location.href = item.url;
        } else {
          window.open(item.url);
        }
      }
    },
    //当前页
    currentChange (item) {
      this.pageNum = item;
      this.getQueryDevelopmentBatch({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      });
      console.log(item);
    },
    //上一页
    prevClick (item) {
      this.pageNum = item;
      this.getQueryDevelopmentBatch({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      });
      console.log(item);
    },
    //下一页
    nextClick (item) {
      this.pageNum = item;
      this.getQueryDevelopmentBatch({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      });
      console.log(item);
    },
  },
  mounted () {
    const that = this;
    window.onresize = () => {
      return (() => {
        window.screenWidth = document.body.clientWidth;
        that.screenWidth = window.screenWidth;
      })();
    };
  },
};
</script>

<style scoped lang="less">
@media screen and (min-width: 1032px) {
  .base {
    width: 1032px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
  .arm-list {
    /deep/.breadcrumb {
      .base;
      height: 28px;
      padding: 16px 0 16px 0;
      justify-content: flex-start;
      align-items: center;
      .el-breadcrumb__inner {
        font-size: 14px;
        font-family: HarmonyOS_Sans_SC;
        color: rgba(0, 0, 0, 0.45);
      }
      .el-breadcrumb__inner.is-link {
        font-weight: 400;
      }
      .now-link {
        .el-breadcrumb__inner {
          color: rgba(0, 0, 0, 0.65);
        }
      }
      .clickable-item {
        &:hover {
          .el-breadcrumb__inner {
            color: #00a6f9;
          }
        }
      }
    }
    .content-wrapper {
      background: #fafafa;
      .content {
        .base;
        flex-wrap: wrap;
        justify-content: flex-start;
        padding-top: 48px;
        .content-item {
          width: 240px;
          padding-bottom: 16px;
          margin-right: 24px;
          margin-bottom: 24px;
          background: #fff;
          border-radius: 8px;
          position: relative;
          display: flex;
          flex-direction: column;
          align-items: center;
          cursor: pointer;
          &:hover {
            position: relative;
            top: -8px;
            box-shadow: 0px 12px 24px 0px rgba(0, 0, 0, 0.06);
          }
          &:nth-child(4n) {
            margin-right: 0;
          }
          .item-status {
            width: 68px;
            height: 25px;
            position: absolute;
            right: 0;
            top: 0;
          }
          .certification {
            background: url("../assets/images/certification.png") no-repeat;
            background-size: contain;
          }
          .under-certification {
            background: url("../assets/images/under-certification.png")
              no-repeat;
            background-size: contain;
          }
          .item-img-wrapper {
            width: 200px;
            height: 200px;
            margin-top: 40px;
            border-radius: 8px;
            img {
              width: 100%;
              height: 100%;
              border-radius: 8px;
            }
          }
          .item-title {
            width: 208px;
            height: 46px;
            line-height: 23px;
            margin: 24px 0 22px;
            padding: 0 16px;
            font-size: 20px;
            font-family: HarmonyOS_Sans_SC_Medium;
            color: rgba(0, 0, 0, 0.85);
            word-break: normal;
            word-wrap: break-word;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-box-pack: center;
            -webkit-box-align: center;
            -webkit-line-clamp: 2;
          }
          .item-origin {
            width: 208px;
            padding: 0 16px;
            height: 40px;
            line-height: 20px;
            font-size: 14px;
            font-family: HarmonyOS_Sans_SC;
            color: rgba(0, 0, 0, 0.45);
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-box-pack: center;
            -webkit-box-align: center;
            -webkit-line-clamp: 2;
            span {
              white-space: nowrap;
            }
          }
        }
      }
    }
    /deep/.pagination {
      width: 100%;
      margin-bottom: 48px;
      .el-pagination {
        float: right;
        .number,
        .btn-prev,
        .btn-next,
        .btn-quickprev,
        .btn-quicknext {
          width: 32px;
          height: 32px;
          padding: 0;
          font-size: 14px;
          font-family: HelveticaNeue;
          background: #ffffff;
          border-radius: 2px;
          border: 1px solid rgba(0, 0, 0, 0.12);
        }
      }
      .el-pagination.is-background .el-pager li:not(.disabled).active {
        background: #242933;
        opacity: 0.9;
      }
    }
  }
}
@media screen and (min-width: 768px) and (max-width: 1032px) {
  .base {
    width: 768px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
  .arm-list {
    /deep/.breadcrumb {
      .base;
      height: 28px;
      padding: 16px 0 16px 0;
      justify-content: flex-start;
      align-items: center;
      .el-breadcrumb__inner {
        font-size: 14px;
        font-family: HarmonyOS_Sans_SC;
        color: rgba(0, 0, 0, 0.45);
      }
      .el-breadcrumb__inner.is-link {
        font-weight: 400;
      }
      .now-link {
        .el-breadcrumb__inner {
          color: rgba(0, 0, 0, 0.65);
        }
      }
      .clickable-item {
        &:hover {
          .el-breadcrumb__inner {
            color: #00a6f9;
          }
        }
      }
    }
    .content-wrapper {
      background: #fafafa;
      .content {
        .base;
        flex-wrap: wrap;
        justify-content: flex-start;
        padding-top: 48px;
        .content-item {
          width: 31%;
          padding-bottom: 16px;
          margin-right: 24px;
          margin-bottom: 24px;
          background: #fff;
          border-radius: 8px;
          position: relative;
          display: flex;
          flex-direction: column;
          align-items: center;
          cursor: pointer;
          &:hover {
            position: relative;
            top: -8px;
            box-shadow: 0px 12px 24px 0px rgba(0, 0, 0, 0.06);
          }
          &:nth-child(3n) {
            margin-right: 0;
          }
          .item-status {
            width: 68px;
            height: 25px;
            position: absolute;
            right: 0;
            top: 0;
          }
          .certification {
            background: url("../assets/images/certification.png") no-repeat;
            background-size: contain;
          }
          .under-certification {
            background: url("../assets/images/under-certification.png")
              no-repeat;
            background-size: contain;
          }
          .item-img-wrapper {
            width: 168px;
            height: 168px;
            margin-top: 40px;
            border-radius: 8px;
            img {
              width: 100%;
              height: 100%;
              border-radius: 8px;
            }
          }
          .item-title {
            width: 208px;
            height: 46px;
            line-height: 23px;
            margin: 24px 0 22px;
            padding: 0 16px;
            font-size: 20px;
            font-family: HarmonyOS_Sans_SC_Medium;
            color: rgba(0, 0, 0, 0.85);
            word-break: normal;
            word-wrap: break-word;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-box-pack: center;
            -webkit-box-align: center;
            -webkit-line-clamp: 2;
          }
          .item-origin {
            width: 208px;
            height: 38px;
            line-height: 19px;
            padding: 0 16px;
            font-size: 14px;
            font-family: HarmonyOS_Sans_SC;
            color: rgba(0, 0, 0, 0.45);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-box-pack: center;
            -webkit-box-align: center;
            -webkit-line-clamp: 2;
            span {
              white-space: nowrap;
            }
          }
        }
      }
    }
    /deep/.pagination {
      width: 100%;
      margin-bottom: 48px;
      display: flex;
      justify-content: center;
      .el-pagination {
        .number,
        .btn-prev,
        .btn-next,
        .btn-quickprev,
        .btn-quicknext {
          width: 32px;
          height: 32px;
          padding: 0;
          font-size: 14px;
          font-family: HelveticaNeue;
          background: #ffffff;
          border-radius: 2px;
          border: 1px solid rgba(0, 0, 0, 0.12);
        }
      }
      .el-pagination.is-background .el-pager li:not(.disabled).active {
        background: #242933;
        opacity: 0.9;
      }
    }
  }
}
@media screen and (max-width: 768px) {
  .base {
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
  .arm-list {
    /deep/.breadcrumb {
      .base;
      height: 28px;
      padding: 13px 0 13px 12px;
      justify-content: flex-start;
      align-items: center;
      .el-breadcrumb__inner {
        font-size: 14px;
        font-family: HarmonyOS_Sans_SC;
        color: rgba(0, 0, 0, 0.45);
      }
      .el-breadcrumb__inner.is-link {
        font-weight: 400;
      }
      .now-link {
        .el-breadcrumb__inner {
          color: rgba(0, 0, 0, 0.65);
        }
      }
      .clickable-item {
        &:hover {
          .el-breadcrumb__inner {
            color: #00a6f9;
          }
        }
      }
    }
    .content-wrapper {
      background: #fafafa;
      .content {
        .base;
        flex-wrap: wrap;
        justify-content: space-between;
        padding: 18px 12px 0;
        .content-item {
          width: 49%;
          padding: 0 12px 16px;
          -moz-box-sizing: border-box;
          -webkit-box-sizing: border-box;
          -o-box-sizing: border-box;
          -ms-box-sizing: border-box;
          box-sizing: border-box;
          margin-bottom: 12px;
          background: #fff;
          border-radius: 8px;
          position: relative;
          display: flex;
          flex-direction: column;
          align-items: center;
          .item-status {
            width: 68px;
            height: 25px;
            position: absolute;
            right: 0;
            top: 0;
          }
          .certification {
            background: url("../assets/images/certification.png") no-repeat;
            background-size: contain;
          }
          .under-certification {
            background: url("../assets/images/under-certification.png")
              no-repeat;
            background-size: contain;
          }
          .item-img-wrapper {
            width: 82%;
            margin-top: 30px;
            border-radius: 8px;
            img {
              width: 100%;
              border-radius: 8px;
            }
          }
          .item-title {
            width: 100%;
            height: 69px;
            line-height: 23px;
            margin: 20px 0 28px;
            font-size: 20px;
            font-family: HarmonyOS_Sans_SC_Medium;
            color: rgba(0, 0, 0, 0.85);
            word-break: normal;
            word-wrap: break-word;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-box-pack: center;
            -webkit-box-align: center;
            -webkit-line-clamp: 3;
          }
          .item-origin {
            width: 100%;
            height: 38px;
            line-height: 19px;
            font-size: 14px;
            font-family: HarmonyOS_Sans_SC;
            color: rgba(0, 0, 0, 0.45);
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-box-pack: center;
            -webkit-box-align: center;
            -webkit-line-clamp: 2;
            span {
              white-space: nowrap;
            }
          }
        }
      }
    }
    /deep/.pagination {
      width: 100%;
      margin: 12px 0 40px;
      .el-pagination {
        float: right;
        .number,
        .btn-prev,
        .btn-next,
        .btn-quickprev,
        .btn-quicknext {
          width: 32px;
          height: 32px;
          padding: 0;
          font-size: 14px;
          font-family: HelveticaNeue;
          background: #ffffff;
          border-radius: 2px;
          border: 1px solid rgba(0, 0, 0, 0.12);
        }
      }
      .el-pagination.is-background .el-pager li:not(.disabled).active {
        background: #242933;
        opacity: 0.9;
      }
    }
  }
}
</style>
